package com.dduggs;

import com.dduggs.object.User;

import java.beans.PropertyEditorSupport;

/**
 * @author Created by CJS on 2018/4/8
 */
public class MyPropertyEditor extends PropertyEditorSupport{

    @Override
    public void setAsText(String text) throws IllegalArgumentException {
        User u=new User();
        String[] textArray=text.split(",");
        u.setName(textArray[0]);
        u.setAge(textArray[1]);
        this.setValue(u);
    }

    public static void main(String[] args) {
        MyPropertyEditor editor=new MyPropertyEditor();
        editor.setAsText("tom,18");
        System.out.println(editor.getValue());
    }
}
